/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package edu.upc.sunat.service;

import edu.upc.sunat.entity.Sunarp;
import edu.upc.sunat.entity.SunarpMsg;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;

/**
 *
 * @author rv
 */
@Stateless
@Path("placa")
public class SunarpFacadeREST extends AbstractFacade<Sunarp> {

    @PersistenceContext(unitName = "WS-SunarpPU")
    private EntityManager em;

    public SunarpFacadeREST() {
        super(Sunarp.class);
    }

//    @POST
//    @Override
//    @Consumes({"application/xml", "application/json"})
//    public void create(Sunarp entity) {
//        super.create(entity);
//    }
//    @PUT
//    @Override
//    @Consumes({"application/xml", "application/json"})
//    public void edit(Sunarp entity) {
//        super.edit(entity);
//    }
//    @DELETE
//    @Path("{id}")
//    public void remove(@PathParam("id") String id) {
//        super.remove(super.find(id));
//    }
    @GET
    @Path("{id}")
    @Produces({"application/xml", "application/json"})
    public SunarpMsg buscarPorPlaca(@PathParam("id") String id) {

        Sunarp sunarp = super.find(id);

        SunarpMsg sunarpMsg = new SunarpMsg();
        
        sunarpMsg.setNumeroPlaca(sunarp.getNumeroPlaca());
        sunarpMsg.setNumeroSerie(sunarp.getNumeroSerie());
        sunarpMsg.setNumeroVin(sunarp.getNumeroVin());
        sunarpMsg.setNumeroMotor(sunarp.getNumeroMotor());
        sunarpMsg.setMarca(sunarp.getMarca());
        sunarpMsg.setModelo(sunarp.getModelo());
        sunarpMsg.setPropietario(sunarp.getPropietario());
        sunarpMsg.setSede(sunarp.getSede());
        sunarpMsg.setEstado(sunarp.getEstado());

        return sunarpMsg;

    }

//    @GET
//    @Override
//    @Produces({"application/xml", "application/json"})
//    public List<Sunarp> findAll() {
//        return super.findAll();
//    }
//    @GET
//    @Path("{from}/{to}")
//    @Produces({"application/xml", "application/json"})
//    public List<Sunarp> findRange(@PathParam("from") Integer from, @PathParam("to") Integer to) {
//        return super.findRange(new int[]{from, to});
//    }
//
//    @GET
//    @Path("count")
//    @Produces("text/plain")
//    public String countREST() {
//        return String.valueOf(super.count());
//    }
    @Override
    protected EntityManager getEntityManager() {
        return em;
    }
}
